/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package util;

import java.util.List;
import javax.faces.model.ListDataModel;
import modelo.Questao;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author jeferson
 */
public class QuestaoModel  extends ListDataModel<Questao> implements SelectableDataModel<Questao>{

    public QuestaoModel() {}  
  
    public QuestaoModel(List<Questao> data) {  
        super(data);  
    }
    
    @Override
    public Object getRowKey(Questao questao) {
        return questao.getQuestao();
    }

    @Override
    public Questao getRowData(String rowKey) {
          
        List<Questao> questoes = (List<Questao>) getWrappedData();  
          
        for(Questao questao : questoes) {  
            if(questao.getQuestao().equals(rowKey))  
                return questao;  
        }  
          
        return null;  
    }
    
}
